package com.review.study;

import java.util.Arrays;

public class StringBufferOperation {
    String a = "bcdefg";
    StringBuffer stringBuffer = new StringBuffer(a);

    public static void main(String[] args) {
        StringBufferOperation stringBufferOperation = new StringBufferOperation();
        stringBufferOperation.myStringBuffer();

    }

    public void myStringBuffer() {
        stringBuffer.append("你是谁");
        System.out.println(stringBuffer);
        //删除部分字符串
        StringBuffer s = stringBuffer.delete(0, 3);
        //删除某个字符
        s.deleteCharAt(0);
        System.out.println(s);
        //插入
        s.insert(0, "你好");
        System.out.println(s);
        //翻转
        s.reverse();
        System.out.println(s);
        //获取
        char f = s.charAt(0);
        //修改
        s.setCharAt(0, 'c');
        char []a=new char[40];
        //转化为数组
        s.getChars(0,3,a,0);
        //转化为数组
        s.toString().toCharArray();
        //替换
        System.out.println(s.replace(0,3,"你好吗"));
    }

}
